const express=require('express');
const db=require('../utils/db.js');

const router=express.Router();

router.get('/get',(req,res)=>{
	const sql=`SELECT id,nickName,headPicture,balance,score,takeawayCoupon,birthday,sex from userinfo where phone='${req.query.phone}';`
	db.query(sql,(err,data)=>{
		if(err){
			res.send({msg:err})
		}else{
			res.send({data:data})
		}
	})
})


router.get('/editsex',(req,res)=>{
	const sql=`UPDATE userinfo set sex='${req.query.sex}' where phone='${req.query.phone}';`
	db.query(sql,(err,data)=>{
		if(err){
			res.send({msg:err})
		}else{
			res.send({msg:'修改成功'})
		}
	})
})

router.get('/editbir',(req,res)=>{
	const sql=`UPDATE userinfo set birthday='${req.query.birthday}' where phone='${req.query.phone}';`
	db.query(sql,(err,data)=>{
		if(err){
			res.send({msg:err})
		}else{
			res.send({msg:'修改成功'})
		}
	})
})


module.exports=router;